package joindemo.utils;

import joindemo.common.enums.RedisCacheEnum;
import joindemo.exception.ServiceException;
import lombok.extern.slf4j.Slf4j;

/**
 * Redis Key 生成工具类
 * @author pym
 */
@Slf4j
public class RedisKeyUtil {

    private RedisKeyUtil() {
        throw new AssertionError("Util class should not be instantiated");
    }
    /**
     * 生成文章草稿缓存 Key
     * 引用 RedisCacheEnum.KeyPrefixes.ARTICLE_DRAFT
     */
    public static String getArticleDraftKey(Long userId, String draftId) {
        if (userId == null || draftId == null) {
            log.error("Redis Key 生成失败: 参数不完整 userId={}, draftId={}", userId, draftId);
            throw new ServiceException("userId 和 draftId 不能为空");
        }
        return RedisCacheEnum.KeyPrefixes.ARTICLE_DRAFT + userId + ":" + draftId;
    }
}